package phongtro.webservice;

import com.google.gson.Gson;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import model.service.*;
import model.entity.*;
import java.util.*;
import javax.ws.rs.PathParam;
import model.dao.PhongTroDAO;
import model.dao.QuanDAO;
import org.json.JSONArray;
import org.json.JSONObject;

@Path("phongtrowebservice")
public class PhongTroService {

    PhongTroDAOService phongService = PhongTroDAO.getInstance();
    QuanDAOService quanDAOService = QuanDAO.getInstance();

    @GET
    @Path("/listquan")
    public String getListQuan() {
        try {
            List<Quan> listQuan = quanDAOService.getAllQuan();
            //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listQuan);
        } catch (Exception e) {
        }
        return null;
    }

    @GET
    @Path("/listphongtro")
    public String getListPhongTro() {
        try {
            List<PhongTro> listPhongTro = phongService.getAllPhong();
            //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhongTro);
        } catch (Exception e) {
        }
        return null;
    }
     @GET
//    @Path("/danhgia/{maphong}/{diemdanhgia}/{diachiMAC}")
    @Path("/danhgia/{madanhgia}/{diemdanhgia}/{songuoidanhgia}/{diachiMAC}")
    public String danhgia(@PathParam("madanhgia") int madanhgia, @PathParam("diemdanhgia") float diemdanhgia,@PathParam("songuoidanhgia") int songuoidanhgia, @PathParam("diachiMAC") String diachiMAC) {

            if(phongService.update_danhgia(madanhgia,diemdanhgia,songuoidanhgia,diachiMAC)==true){
                return "";
            }else
            return "";

    }
    
}


